﻿create   function   [dbo].[f_int_hex](@num int,@len int)   
--@num 为要转换成16进制的10进制数,@len为转换后占用的位数
returns   varchar(100)   
as   
begin   
      declare   @result   varchar(100)   
      set   @result=''   
      while   len(@result)<@len   
          select   @result=substring('0123456789ABCDEF',@num%16+1,1)+@result,@num=@num/16   
      return(@result)   
end